import {createStore,combineReducers,applyMiddleware} from 'redux';
import thunk from 'redux-thunk'

const userReducer = ((state={userList:[1,2,3]},action) => {
    switch(action.type){
        case 'search':
            return {userList:action.content}
        case 'add':
            return {...state,userList:[action.content,...state.userList]}
        case 'delete':
            return {userList:action.content}
        case 'editor':
            return {userList:[action.content,...state.userList]}
        default:
            return state;
        }
})

const loginReducer = ((state={islogin:false,sta:{}},action) => {
    switch(action.type){
        case 'login':
            return {islogin:true,sta:action.value}
        case 'exit':
            return {islogin:false,sta:{}}
        default:
            return state;
    }
})

const recruitReducer = ((state={recruitList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,recruitList:[action.content,...state.recruitList]}
        case 'add':
            return {...state,recruitList:[action.content,...state.recruitList]}
        case 'delete':
            return {...state,recruitList:[action.content,...state.recruitList]}
        case 'editor':
            return {...state,recruitList:[action.content,...state.recruitList]}
        default:
            return state;
        }
})

const checkReducer = ((state={checkList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,checkList:[action.content,...state.checkList]}
        case 'add':
            return {...state,checkList:[action.content,...state.checkList]}
        case 'delete':
            return {...state,checkList:[action.content,...state.checkList]}
        case 'editor':
            return {...state,checkList:[action.content,...state.checkList]}
        default:
            return state;
        }
})

const wordReducer = ((state={wordList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,wordList:[action.content,...state.wordList]}
        case 'add':
            return {...state,wordList:[action.content,...state.wordList]}
        case 'delete':
            return {...state,wordList:[action.content,...state.wordList]}
        case 'editor':
            return {...state,wordList:[action.content,...state.wordList]}
        default:
            return state;
        }
})

const wordhistoryReducer = ((state={wordhistoryList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,wordhistoryList:[action.content,...state.wordhistoryList]}
        case 'add':
            return {...state,wordhistoryList:[action.content,...state.wordhistoryList]}
        case 'delete':
            return {...state,wordhistoryList:[action.content,...state.wordhistoryList]}
        case 'editor':
            return {...state,wordhistoryList:[action.content,...state.wordhistoryList]}
        default:
            return state;
        }
})

const scoreReducer = ((state={scoreList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,scoreList:[action.content,...state.scoreList]}
        case 'add':
            return {...state,scoreList:[action.content,...state.scoreList]}
        case 'delete':
            return {...state,scoreList:[action.content,...state.scoreList]}
        case 'editor':
            return {...state,scoreList:[action.content,...state.scoreList]}
        default:
            return state;
        }
})

const numberReducer = ((state={numberList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,numberList:[action.content,...state.numberList]}
        case 'add':
            return {...state,numberList:[action.content,...state.numberList]}
        case 'delete':
            return {...state,numberList:[action.content,...state.numberList]}
        case 'editor':
            return {...state,numberList:[action.content,...state.numberList]}
        default:
            return state;
        }
})

const knowledgeReducer = ((state={knowledgeList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,knowledgeList:[action.content,...state.knowledgeList]}
        case 'add':
            return {...state,knowledgeList:[action.content,...state.knowledgeList]}
        case 'delete':
            return {...state,knowledgeList:[action.content,...state.knowledgeList]}
        case 'editor':
            return {...state,knowledgeList:[action.content,...state.knowledgeList]}
        default:
            return state;
        }
})

const policyReducer = ((state={policyList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,policyList:[action.content,...state.policyList]}
        case 'add':
            return {...state,policyList:[action.content,...state.policyList]}
        case 'delete':
            return {...state,policyList:[action.content,...state.policyList]}
        case 'editor':
            return {...state,policyList:[action.content,...state.policyList]}
        default:
            return state;
        }
})

const chooseReducer = ((state={chooseList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,chooseList:[action.content,...state.chooseList]}
        case 'add':
            return {...state,chooseList:[action.content,...state.chooseList]}
        case 'delete':
            return {...state,chooseList:[action.content,...state.chooseList]}
        case 'editor':
            return {...state,chooseList:[action.content,...state.chooseList]}
        default:
            return state;
        }
})

const guideReducer = ((state={guideList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,guideList:[action.content,...state.guideList]}
        case 'add':
            return {...state,guideList:[action.content,...state.guideList]}
        case 'delete':
            return {...state,guideList:[action.content,...state.guideList]}
        case 'editor':
            return {...state,guideList:[action.content,...state.guideList]}
        default:
            return state;
        }
})

const bookReducer = ((state={bookList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,bookList:[action.content,...state.bookList]}
        case 'add':
            return {...state,bookList:[action.content,...state.bookList]}
        case 'delete':
            return {...state,bookList:[action.content,...state.bookList]}
        case 'editor':
            return {...state,bookList:[action.content,...state.bookList]}
        default:
            return state;
        }
})

const circleReducer = ((state={circleList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,circleList:[action.content,...state.circleList]}
        case 'add':
            return {...state,circleList:[action.content,...state.circleList]}
        case 'delete':
            return {...state,circleList:[action.content,...state.circleList]}
        case 'editor':
            return {...state,circleList:[action.content,...state.circleList]}
        default:
            return state;
        }
})

const usercomsReducer = ((state={usercomsList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,usercomsList:[action.content,...state.usercomsList]}
        case 'add':
            return {...state,usercomsList:[action.content,...state.usercomsList]}
        case 'delete':
            return {...state,usercomsList:[action.content,...state.usercomsList]}
        case 'editor':
            return {...state,usercomsList:[action.content,...state.usercomsList]}
        default:
            return state;
        }
})

const messageReducer = ((state={messageList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,messageList:[action.content,...state.messageList]}
        case 'add':
            return {...state,messageList:[action.content,...state.messageList]}
        case 'delete':
            return {...state,messageList:[action.content,...state.messageList]}
        case 'editor':
            return {...state,messageList:[action.content,...state.messageList]}
        default:
            return state;
        }
})

const composeReducer = ((state={composeList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,composeList:[action.content,...state.composeList]}
        case 'add':
            return {...state,composeList:[action.content,...state.composeList]}
        case 'delete':
            return {...state,composeList:[action.content,...state.composeList]}
        case 'editor':
            return {...state,composeList:[action.content,...state.composeList]}
        default:
            return state;
        }
})

const collectReducer = ((state={collectList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,collectList:[action.content,...state.collectList]}
        case 'add':
            return {...state,collectList:[action.content,...state.collectList]}
        case 'delete':
            return {...state,collectList:[action.content,...state.collectList]}
        case 'editor':
            return {...state,collectList:[action.content,...state.collectList]}
        default:
            return state;
        }
})

const examhistoryReducer = ((state={examhistoryList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,examhistoryList:[action.content,...state.examhistoryList]}
        case 'add':
            return {...state,examhistoryList:[action.content,...state.examhistoryList]}
        case 'delete':
            return {...state,examhistoryList:[action.content,...state.examhistoryList]}
        case 'editor':
            return {...state,examhistoryList:[action.content,...state.examhistoryList]}
        default:
            return state;
        }
})

const studyhistoryReducer = ((state={studyhistoryList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,studyhistoryList:[action.content,...state.studyhistoryList]}
        case 'add':
            return {...state,studyhistoryList:[action.content,...state.studyhistoryList]}
        case 'delete':
            return {...state,studyhistoryList:[action.content,...state.studyhistoryList]}
        case 'editor':
            return {...state,studyhistoryList:[action.content,...state.studyhistoryList]}
        default:
            return state;
        }
})

const systemReducer = ((state={systemList:[]},action) => {
    switch(action.type){
        case 'search':
            return {...state,systemList:[action.content,...state.systemList]}
        case 'add':
            return {...state,systemList:[action.content,...state.systemList]}
        case 'delete':
            return {...state,systemList:[action.content,...state.systemList]}
        case 'editor':
            return {...state,systemList:[action.content,...state.systemList]}
        default:
            return state;
        }
})

const value = ((state={valueList:{}},action) => {
    switch(action.type){
        case 'get':
            return {valueList:action.con}
        default:
            return state;
        }
})

const rootReducer = combineReducers({
    login:loginReducer,
    user:userReducer,
    recruit:recruitReducer,
    check:checkReducer,
    word:wordReducer,
    wordhistory:wordhistoryReducer,
    score:scoreReducer,
    number:numberReducer,
    knowledge:knowledgeReducer,
    policy:policyReducer,
    choose:chooseReducer,
    guide:guideReducer,
    book:bookReducer,
    circle:circleReducer,
    usercoms:usercomsReducer,
    message:messageReducer,
    compose:composeReducer,
    collect:collectReducer,
    examhistory:examhistoryReducer,
    studyhistory:studyhistoryReducer,
    system:systemReducer,
    value:value
})

const store = createStore(
    rootReducer,
    applyMiddleware(thunk)
)

export default store;